#include "lcd_App.h"



void LCD_Test(void)
{
    char dispBuf[100];
    static uint8_t testCnt = 0;
    
    testCnt++;
    LCD_SetFont(&Font8x16);
    LCD_SetColors(RED,BLACK);

    ILI9341_Clear(0, 0, LCD_X_LENGTH, LCD_Y_LENGTH);

    ILI9341_DispStringLine_EN(LINE(0), "BH 3.2 inch LCD para:");
    ILI9341_DispStringLine_EN(LINE(1), "Image resolution:240*320 px");
    ILI9341_DispStringLine_EN(LINE(2), "ILI9341 LCD Driver");
    ILI9341_DispStringLine_EN(LINE(3), "XPT2046 Touch Pad driver");

    LCD_SetFont(&Font16x24);
    LCD_SetTextColor(GREEN);

    sprintf(dispBuf,"count: %d ", testCnt);
    LCD_ClearLine(LINE(4));

    ILI9341_DispStringLine_EN(LINE(4),dispBuf);

    LCD_SetFont(&Font24x32);

    LCD_ClearLine(LINE(4));
    LCD_SetTextColor(BLUE);

    ILI9341_DispStringLine_EN(LINE(4),"Draw line:");

    LCD_SetTextColor(RED);
    ILI9341_DrawLine(50, 170, 210, 230);
    ILI9341_DrawLine(50, 200, 210, 240);

    LCD_SetTextColor(GREEN);
    ILI9341_DrawLine(100, 170, 110, 230);
    ILI9341_DrawLine(100, 200, 220, 240);

    LCD_SetTextColor(BLUE);
    ILI9341_DrawLine(110, 170, 110, 230);
    ILI9341_DrawLine(130, 200, 220, 240);

    vTaskDelay(10000);

    ILI9341_Clear(0, 16*8, LCD_X_LENGTH, LCD_Y_LENGTH-16*8);

    LCD_ClearLine(LINE(4));
    LCD_SetTextColor(BLUE);

    ILI9341_DispStringLine_EN(LINE(4), "Draw Rect:");

    LCD_SetTextColor(RED);
    ILI9341_DrawRectangle(50, 200, 100, 30, 1);

    LCD_SetTextColor(GREEN);
    ILI9341_DrawRectangle(160, 200, 20, 40, 0);

    LCD_SetTextColor(BLUE);
    ILI9341_DrawRectangle(170, 200, 50, 40, 0);
    vTaskDelay(10000);

    ILI9341_Clear(0, 16*8, LCD_X_LENGTH, LCD_Y_LENGTH-16*8);
    LCD_ClearLine(LINE(4));
    LCD_SetTextColor(BLUE);

    ILI9341_DispStringLine_EN(LINE(4), "Draw cir:");

    LCD_SetTextColor(RED);
    ILI9341_DrawCircle(100, 200, 20, 0);

    LCD_SetTextColor(GREEN);
    ILI9341_DrawCircle(100, 200, 10, 1);

    LCD_SetTextColor(BLUE);
    ILI9341_DrawCircle(140, 200, 20, 0);
    vTaskDelay(10000);

    ILI9341_Clear(0, 16*8, LCD_X_LENGTH, LCD_Y_LENGTH-16*8);

    if(testCnt == 200)
    {
        testCnt = 0;
    }

}

void LCD_Task(void *parameters)
{
    ILI9341_GramScan(6);

    while(1)
    {
        LCD_Test();
//        vTaskDelay(1000);
    }
}

